﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EPiServer.Core;
using EPiServer.Municipality.Extensions;


namespace EPiServer.Municipality.Templates.MobilePages {

    public partial class Contact : TemplatePage
    {


        #region public string PhoneGeneral
        /// <summary>
        /// Gets the PhoneGeneral of the Contact
        /// </summary>
        /// <value></value>
        public string PhoneGeneral
        {
            get
            {
                if (CurrentPage.IsValue("ContactPhoneNumberGeneral"))
                    return string.Format("<li><h2>{0} </h2><a href='tel:{1}'>{1}</a></li>", Translate("/mobilemunicipality/templates/contact/phonegeneral"), CurrentPage["ContactPhoneNumberGeneral"]);
                return String.Empty;
            }
        }
        #endregion
        #region public string PhoneDirect
        /// <summary>
        /// Gets the PhoneDirect of the ContactCard
        /// </summary>
        /// <value></value>
        public string PhoneDirect
        {
            get
            {
                if (CurrentPage.IsValue("ContactPhoneNumberDirectly"))
                    return string.Format("<li><h2>{0} </h2><a href='tel:{1}'>{1}</a></li>", Translate("/mobilemunicipality/templates/contact/phonedirect"), CurrentPage["ContactPhoneNumberDirectly"]);
                return String.Empty;
            }
        }
        #endregion

        #region public string PhoneMobile
        /// <summary>
        /// Gets the Phonemobile of the Contact
        /// </summary>
        /// <value></value>
        public string PhoneMobile
        {
            get
            {
                if (CurrentPage.IsValue("ContactPhoneNumberMobile"))
                    return string.Format("<li><h2>{0} </h2><a href='tel:{1}'>{1}</a></li>", Translate("/mobilemunicipality/templates/contact/phonemobile"), CurrentPage["ContactPhoneNumberMobile"]);
                return String.Empty;
            }
        }
        #endregion
        
        #region public string Address
        /// <summary>
        /// Gets the Address of the Contact
        /// </summary>
        /// <value></value>
        public string Address
        {
            get
            {
                string strAddress = String.Empty;
                if (CurrentPage.IsValue("ContactStreetAddress"))
                    strAddress = "<li><h2>" + Translate("/mobilemunicipality/templates/contact/streetaddress")+ "</h2>" + CurrentPage["ContactStreetAddress"];
                if (CurrentPage.IsValue("ContactPostalNumber") || CurrentPage.IsValue("ContactAddress"))
                    strAddress += " " + CurrentPage["ContactPostalNumber"] + " " + CurrentPage["ContactAddress"]+"</li>";
                if (CurrentPage.IsValue("ContactBoxAddress"))
                    strAddress += "<li>" + "<h2>Boxadress: </h2>" + CurrentPage["ContactBoxAddress"] + "</li>";

                return strAddress;
            }
        }
        #endregion

        #region public string Information
        /// <summary>
        /// Gets the Information of the Contact
        /// </summary>
        /// <value></value>
        public string Information
        {
            get
            {
                if (CurrentPage.IsValue("ContactInformation"))
                    return "<p>" + CurrentPage["ContactInformation"] + "</p>";
                return String.Empty;
            }
        }
        #endregion
        #region public string Link
        /// <summary>
        /// Gets the Link of the Contact
        /// </summary>
        /// <value></value>
        public string Link
        {
            get
            {
                if (CurrentPage.IsValue("ContactLink") && CurrentPage.IsValue("ContactLinkText"))
                {
                    if (CurrentPage["ContactLink"].ToString().ToLower().IndexOf("://") > -1)
                        return String.Format("<li><h2>Länkar: </h2><a href=\"{0}\" >{1}</a></li>", CurrentPage["ContactLink"], CurrentPage["ContactLinkText"]);
                    return String.Format("<li><h2>Länkar: </h2><a href=\"{0}\" >{1}</a></li>", CurrentPage["ContactLink"], CurrentPage["ContactLinkText"]);
                }
                return String.Empty;
            }
        }
        #endregion

        #region public string Name
        /// <summary>
        /// Gets the Name of the Contact
        /// </summary>
        /// <value></value>
        public string Name
        {
            get
            {
                if (CurrentPage.IsValue("ContactEmail"))
                    return String.Format("<li><h2>E-mail: </h2><a href=\"mailto:{0}\" >{1}</a></li>", CurrentPage["ContactEmail"], CurrentPage["ContactEmail"]);
                return CurrentPage.PageName;
            }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e) {

        }
    }
}